package com.example.hyznbk.utils;

import android.app.Activity;
import android.view.WindowManager;

/**
 * Created by tangminglong on 17/9/21.
 * Windows 设置工具类
 */

public class WindowUtils {

    /**
     * 设置背景透明度
     * @param bgAlpha
     */
    public static void setBackgroundAlpha(Activity context, float bgAlpha){
        WindowManager.LayoutParams lp = context.getWindow().getAttributes();
        lp.alpha = bgAlpha;
        context.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
        context.getWindow().setAttributes(lp);
    }

    public static void setBackgroundHalfAlpha(Activity context){
        setBackgroundAlpha(context,0.4f);
    }

    public static void setBackgroundFullAlpha(Activity context){
        setBackgroundAlpha(context,1.0f);
    }
}
